<?php

namespace App\Modules\Article;

use App\Modules\AdapterApi;
use app\serverarticle\logic\Article;
use App\Services\Article\ArticleIndex;

/**
 * 文章应用层
 * Class ApiArticle
 * @package App\Modules\Article
 */
class ApiArticle extends AdapterApi
{
    /**
     * 文章添加
     */
    public function add()
    {
        $data = pick_array($this->postData,["department_ids", "content"]);
        return ArticleIndex::ApiArticle()->add($data);
    }

    /**
     * 文章编辑
     */
    public function edit()
    {
        $data = pick_array($this->postData,["id", "classify_id", "content"]);
        return ArticleIndex::ApiArticle()->edit($data);
    }

    /**
     *某篇文章置顶
     * @return mixed
     */
    public function top()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->top($data);
    }

    /**
     * 取消谋篇文章置顶
     * @return mixed
     */

    public function cancelTop()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->cancelTop($data);
    }

    /**
     * 文章推荐
     */
    public function recommended()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->recommended($data);
    }

    /**
     * 取消推荐某篇文章
     * @return mixed
     */
    public function cancelRecommended()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->cancelRecommended($data);
    }

    /**
     * 删除某篇文章
     * @return mixed
     */
    public function delete()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->delete($data);
    }

    /**
     * 恢复启用某篇文章
     */
    public function enable()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->enable($data);
    }


    /**
     * 上架重新发布某篇文章
     * @return mixed
     */
    public function release()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->release($data);
    }

    /**
     * 下架发布某篇文章
     * @return mixed
     */
    public function cancelRelease()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->cancelRelease($data);
    }

    /**
     * 文章阅读权限 仅自己可见
     * @return mixed
     */
    public function oneselfVisible()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->oneselfVisible($data);
    }

    /**
     * 阅读权限 所有人可见
     * @return mixed
     */
    public function everyoneVisible()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->everyoneVisible($data);
    }

    /**
     * 阅读权限 指定人可见
     * @return mixed
     */
    public function nominatorVisible()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->nominatorVisible($data);
    }

    /**
     * 阅读权限 指定人不可见
     */
    public function nominatorInvisible()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->nominatorInvisible($data);

    }

    /**
     * 评论权限 允许评论
     * @return mixed
     */
    public function review()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->review($data);
    }

    /**
     * 评论权限 禁止评论
     * @return mixed
     */
    public function banReview()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->banReview($data);
    }

    /**
     * 转载权限 允许转载
     */
    public function reprinted()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->reprinted($data);
    }

    /**
     * 转载权限 禁止转载
     * @return mixed
     */
    public function banReprinted()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->banReprinted($data);
    }

    /**
     * 审核通过
     * @return mixed
     */
    public function audit()
    {
        $data = pick_array($this->postData,['id','audit_id']);

        return ArticleIndex::ApiArticle()->audit($data);
    }

    /**
     * 审核失败
     * @return mixed
     */
    public function auditFailure()
    {
        $data = pick_array($this->postData,['id','audit_id']);

        return ArticleIndex::ApiArticle()->auditFailure($data);
    }

    /**
     * 文章可见人指定
     * @return mixed
     */
    public function visible()
    {
        $data = pick_array($this->postData,['id','visible']);

        return ArticleIndex::ApiArticle()->visible($data);
    }

    /**
     * 指定文章不可见人
     * @return mixed
     */
    public function invisible()
    {
        $data = pick_array($this->postData,['id','invisible']);

        return ArticleIndex::ApiArticle()->invisible($data);
    }

    /**
     * 点赞次数 +1
     * @return mixed
     */
    public function praise()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->praise($data);
    }

    /**
     * 踩 次数 +1
     * @return mixed
     */
    public function trample()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->trample($data);
    }

    /**
     * 获取文章列表
     * @return mixed
     */
    public function articleList()
    {
        $data = $this->postData;
        return ArticleIndex::ApiArticle()->articleList($data);
    }

    /**
     * 获取某一类置顶状态文章列表 非删除
     * @return mixed
     */
    public function topList()
    {
        $data = pick_array($this->postData,['classify_id',"page","listRows"]);

        return ArticleIndex::ApiArticle()->topList($data);
    }

    /**
     * 获取某一类推荐状态文章列表 非删除
     * @return mixed
     */
    public function recommendedList()
    {
        $data = pick_array($this->postData,['classify_id',"page","listRows"]);

        return ArticleIndex::ApiArticle()->recommendedList($data);
    }

    /**
     * 获取某一篇文章信息 非删除
     * @return mixed
     */
    public function articleInfo()
    {
        $data = pick_array($this->postData,['id']);

        return ArticleIndex::ApiArticle()->articleInfo($data);
    }
}